<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1. news 新闻
        fetch("http://ajax-api.itheima.net/api/news").then(res => res.json()).then(({ data }) => console.log(data))

        // 2. 登录
        fetch("http://ajax-api.itheima.net/api/login", {
            method: 'POST',
            headers: {
                'content-type': 'application/json'
            },
            body: JSON.stringify({
                username: 'admin',
                password: '123456'
            })
        }).then(res => res.json()).then((res) => console.log(res))

        // 3. 机器人
        fetch("http://ajax-api.itheima.net/api/robot?spoken=王磊好帅").then(res => res.json()).then(res => console.log(res))
    </script>
</body>

</html>